COMMON_DIR      ?= ..

BIN2MEM         := $(COMMON_DIR)/_scripts/bin2mem
BIN2COE         := $(COMMON_DIR)/_scripts/bin2coe

RTLPATH         := $(COMMON_DIR)/../soc/tb
CP              := cp

ISET            ?= i
INST            ?= add

BINFILE         := ./PASS/rv32$(ISET)/rv32u$(ISET)-p-$(INST).bin

.PHONY: all
all:
ifneq ($(wildcard $(BINFILE)),)
	$(BIN2MEM) $(BINFILE) inst.data
	$(BIN2COE) $(BINFILE) inst.coe
	$(CP) inst.data $(RTLPATH)/inst_rom.data
	$(CP) inst.coe $(RTLPATH)/inst_rom.coe
endif

.PHONY: clean
clean:
	rm -f *.data *.coe